import request from '@/utils/request'

export default {
    selectAllUser(){
        const req = request({
            method: 'get',
            url: '/dgut/getAllUser'
        })
        return req;
    },
    search(searchMap) {
        if (searchMap.openid != "") {
            const req = request({
                method: 'get',
                url: '/dgut/selectUserByOpenid',
                params: {
                    openid:searchMap.openid
                }
            })
            return req;
        } else if (searchMap.nickName != "") {
            const req = request({
                method: 'get',
                url: '/dgut/getUserByName',
                params: {
                    nickName:searchMap.nickName
                }
            })
            return req;
        } else if(searchMap.gender != ""){
            const req = request({
                method: 'get',
                url: '/dgut/getUserByGender',
                params: {
                    gender:searchMap.gender
                }
            })
            return req;
        }if(searchMap.tag != ""){
            const req = request({
                method: 'get',
                url: '/dgut/getUserByTag',
                params: {
                    tag:searchMap.tag
                }
            })
            return req;
        }else{
            const req = request({
                method: 'get',
                url: '/dgut/getAllUser'
            })
            return req;
        }
    },
    editOneUser(userMessage){
        const req = request({
            method: 'put',
            url: '/dgut/updateUserMessage',
            params: {
                codes:sessionStorage.getItem("codes"),
                openid:userMessage.openid,
                tag:userMessage.tag
            }
        })
        return req;
    },
    deleteOneUser(openid){
        const req = request({
            method: 'delete',
            url: '/dgut/deleteOneUser',
            params:{
                codes:sessionStorage.getItem("codes"),
                openid
            }
        })
        return req;
    },
    selectUserByOpenid(openid){
        const req = request({
            method: 'get',
            url: '/dgut/selectUserByOpenid',
            params: {
                openid
            }
        })
        return req;
    },
}